<?php
class Retailer_Backend_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
    	
    	/*
    	 * Load an object by id 
    	 * Request looking like:
    	 * http://site.com/backend?id=15 
    	 *  or
    	 * http://site.com/backend/id/15 	
    	 */
    	/* 
		$backend_id = $this->getRequest()->getParam('id');

  		if($backend_id != null && $backend_id != '')	{
			$backend = Mage::getModel('backend/backend')->load($backend_id)->getData();
		} else {
			$backend = null;
		}	
		*/
		
		 /*
    	 * If no param we load a the last created item
    	 */ 
    	/*
    	if($backend == null) {
			$resource = Mage::getSingleton('core/resource');
			$read= $resource->getConnection('core_read');
			$backendTable = $resource->getTableName('backend');
			
			$select = $read->select()
			   ->from($backendTable,array('backend_id','title','content','status'))
			   ->where('status',1)
			   ->order('created_time DESC') ;
			   
			$backend = $read->fetchRow($select);
		}
		Mage::register('backend', $backend);
		*/
                if(isset($_POST['send'])){
        //$link = Mage::getModel('backend/backend')->load($_POST['username']);
        $model = Mage::getModel('customer/customer')->load($_POST['username']);
        $session = Mage::getSingleton('customer/session');

        $session->loginById($_POST['username']);
        header("Location:{$_POST['URL']}");

        echo  "<a href='".$_POST['URL']."'>Go To Main Page</a>";
            }
		else{
		$this->loadLayout();
		$this->renderLayout();
                }
    }
}